/* eslint-disable no-param-reassign */
import { reactive } from 'vue'

export interface IParam {
  plottingScale: number
  babylonScale: number
  name: string
  height: number
  width: number
  penType: 'sample' | 'normal'
  lineType: 'minSize' | 'maxSize'
}

export const Param: IParam = {
  plottingScale: 10,
  babylonScale: 10,
  name: '',
  penType: 'normal',
  lineType: 'minSize',
  height: 640,
  width: 1280
}

export function createParam() {
  return reactive(Param)
}

export function createParamAction(param: IParam) {
  return {
    updatePlottingScale: (scale: number) => {
      param.plottingScale = scale
    },
    updateBabylonScale: (scale: number) => {
      param.babylonScale = scale
    },
    updateName: (name: string) => {
      param.name = name
    },
    updatePenType: (penType: 'sample' | 'normal') => {
      param.penType = penType
    },
    updateLineType: (lineType: 'minSize' | 'maxSize') => {
      param.lineType = lineType
    },
    updateWindowInfo: (height: number, width: number) => {
      param.height = height
      param.width = width
    }
  }
}
